<?php
/**
 * Description:  门店管理
 * Created by PhpStorm.
 * User: 玉坤
 * Date: 2021/9/9
 * Time: 14:04
 */


ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
ini_set('memory_limit', '1024M');

require_once '/data/wwwroot/g_vendor/autoload.php';


$start = microtime(true);
$page = 1;
$pageSize = 1000;
$lists = [];
$all_num = 0;

do {
    $limit = [($page - 1) * $pageSize, $pageSize];
    $where = [
        'city_id[>]' => 0,
        "LIMIT" => $limit,
//        "shop_status" => 1
    ];
    $lists = \Biz\model\brand\ShopAddres::getDataBywhere($where);

    $data = [];

    foreach ($lists as $list) {
        try {
            $code = \Hhz\AdministrativeRegion\Region::getCodeByOldCode($list['city_id']) ?? '';
            $data = [
                'area_code' => $code,
                'area_name' => \Hhz\AdministrativeRegion\Region::getNameByCode($code) ?? ''
            ];
            \Biz\model\brand\ShopAddres::updateById($list['id'], $data);
        } catch (\Exception $e) {
            print $e->getMessage();
            exit();
        }
    }
    $page++;
} while ($lists);

$end = microtime(true);
$time = $end - $start;
$second = round($time, 3);
var_dump('完成时间：' . date('Y-m-d H:i:s') . '   总耗时:' . $second . '秒');

